package tool;

import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;

public class MacroDumper {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		if(args.length < 2){
			System.err.println("needs 2 args [inputPath] [outputPath]");
			return;
		}


		String line = "";

		FileInputStream fis =null;
		DataInputStream dis = null;

		FileWriter fw = null;

		try {
			fis = new FileInputStream(args[0]);
			dis = new DataInputStream(fis);

			int len = dis.readByte();
			for(int i = 0; i < len; i++){
				line += dis.readUTF();
				line += "\t";
				line += dis.readUTF();
				line += "\n";
			}

			fw = new FileWriter(args[1]);
			fw.write(line);
			fw.flush();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			try {
				fw.close();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
			try {
				dis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			try {
				fis.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}
